#pragma once

#include "const.h"

class LogicSystem;

class MsgNode
{
public:
	MsgNode(short max_len)
		: _total_len(max_len)
		, _cur_len(0)
	{
		_data = new char[(std::size_t)_total_len + 1]();
		_data[_total_len] = '\0';
	}

	~MsgNode() {
		std::cout << "MsgNode destructor" << std::endl;
	}

	void Clear() {
		::memset(_data, 0, _total_len);
		_cur_len = 0;
	}

	short _cur_len;
	short _total_len;
	char* _data;
};

class SendNode
	: public MsgNode
{
	friend class LogicSystem;
public:
	SendNode(const char * msg, short max_len, short msg_id);
private:
	short _msg_id;
};

class RecvNode
	: public MsgNode
{
	friend class LogicSystem;
public:
	RecvNode(short max_len, short msg_id);
private:
	short _msg_id;
};